import Vue from 'vue'
import App from './App'
import router from './router'
import 'common/stylus/index.styl'
import YDUI from 'vue-ydui';
import 'vue-ydui/dist/ydui.rem.css';
import axios from 'axios'
import stores from './store/store'
import VueLazyLoad from 'vue-lazyload'

//ui框架
Vue.use(YDUI);
               
//import vConsole from 'vconsole' //手机测试

//global.baseURL = 'http://192.168.31.148/card.php?' //内网
// global.baseURL = 'http://www.weiweishai.net/card.php?' //外网
global.baseURL = 'http://192.168.0.100/card.php?' //外网
global.baseWeChatURL = 'http://www.weiweishai.net/' //微信地址


global.versionNumber = '0.0.6'


//图片懒加载
Vue.use(VueLazyLoad, {
  loading: require('common/image/loading.gif'),
  error: require('common/image/error.png')
})


//请求超时
axios.defaults.retry = 1;
axios.defaults.retryDelay = 5000;
axios.interceptors.response.use(undefined, function axiosRetryInterceptor(err) {
  var config = err.config;
  // If config does not exist or the retry option is not set, reject
  if (!config || !config.retry) return Promise.reject(err);
  // Set the variable for keeping track of the retry count
  config.__retryCount = config.__retryCount || 0;
  // Check if we've maxed out the total number of retries
  if (config.__retryCount >= config.retry) {
    // Reject with the error
    return Promise.reject(err);
  }
  // Increase the retry count
  config.__retryCount += 1;
  // Create new promise to handle exponential backoff
  var backoff = new Promise(function (resolve) {
    setTimeout(function () {
      resolve();
    }, config.retryDelay || 1);
  });
  // Return the promise in which recalls axios to retry the request
  return backoff.then(function () {
    return axios(config);
  });
});


Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store: stores,
  components: {App},
  template: '<App/>'
})
